package com.specialized.pay.compensate;

import com.alipay.api.AlipayApiException;
import com.specialized.pay.domain.Trade;
import com.specialized.pay.service.ITradeService;
import com.specialized.pay.service.PayService;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author：wangxinyu
 * @Package：com.specialized.pay.compensate
 * @Project：Specialized-Cloud
 * @name：PayCompenSate
 * @Date：2024/7/25 8:47
 */
@Component
public class PayCompenSate {
    @Autowired
    private ITradeService tradeService;
    @Autowired
    private PayService payService;

    @XxlJob("alipayCompensate")
    public void alipayCompensate() throws AlipayApiException {
        //查询正在进行中的数据
        Trade trade = new Trade();
        trade.setStatus(1L);
        List<Trade> trades = tradeService.selectTradeList(trade);
        //去支付宝查询 成功 修改状态为成功 其他修改成 关闭
        if (trades.size() > 0){
            for (Trade trade1 : trades) {
                payService.alipayTradeQuery(trade1.getOuttradeno());
            }
        }
    }






}
